<?php

/**
 *  物流信息
*/

namespace app\api\controller;
use app\facade\Basic;
use think\Request;
use app\api\service\Logistics as ServiceLogistics;

class Logistics extends BaseController
{

    /**
     *  通过订单获取运费
    */
    public function orderFee(Request $request)
    {

        $param['product'] = $request->param('product',[]);
        $param['address_id'] = $request->param('address_id',null);
        $param['terms'] = $request->param('terms',null);
        $param['prescription'] = $request->param('prescription',null);

        /* 验证 */
        $this->validateData($param,'Logistics.cart');

        $ServiceLogistics = new ServiceLogistics();
        $result = $ServiceLogistics->fee($param);

        return Basic::json($result);
    }
    /**
     *  通过订单获取运费
     */
    public function shippingMethod(Request $request)
    {

        $param['product'] = $request->param('product',[]);
        $param['address_id'] = $request->param('address_id',null);
        $param['terms'] = $request->param('terms',null);
        $param['prescription'] = $request->param('prescription',null);

        /* 验证 */
        $this->validateData($param,'Logistics.cart');

        $ServiceLogistics = new ServiceLogistics();
        $result = $ServiceLogistics->shippingMethod($param);

        return Basic::json($result);
    }

    /**
     *  通过购物获取物流费用
    */
    public function fee(Request $request)
    {
        $param['product'] = $request->param('product',null);
        $param['terms'] = $request->param('terms',null);
        $param['prescription'] = $request->param('prescription',null);

        /* 验证 */
        $this->validateData($param,'Logistics.cart');

        $ServiceLogistics = new ServiceLogistics();
        $result = $ServiceLogistics->orderFee($param);
        return Basic::json($result);
    }




}
